package com.demo.paypalmanagement.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.paypalmanagement.common.BuildQuery;
import com.demo.paypalmanagement.common.ResultMsg;
import com.demo.paypalmanagement.config.response.BizException;
import com.demo.paypalmanagement.model.entity.LotteryRecord;
import com.demo.paypalmanagement.model.entity.Order;
import com.demo.paypalmanagement.model.vo.LotteryRecordVO;
import com.demo.paypalmanagement.service.LotteryRecordService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/lottery")
public class LotteryRecordController {

    @Autowired
    private LotteryRecordService lotteryRecordService;

    @GetMapping("/page")
    public IPage<LotteryRecordVO> page(LotteryRecordVO vo) {
        if (ObjectUtils.isEmpty(vo)) {
            throw new BizException(ResultMsg.OBJECT_IS_EMPTY.getMsg());
        }

        Page<LotteryRecord> page = new Page<>(vo.getPageNo(), vo.getPageSize());
        page.setCurrent(vo.getPageNo()-1);

        return lotteryRecordService.customPage(page,vo);
    }
}
